#ifndef DATAQUICK_H
#define DATAQUICK_H

#include <QObject>
#include <QMap>

class DataQuick : public QObject
{
    Q_OBJECT
public:
    DataQuick() {}
    virtual ~DataQuick() {}

    /*
     * {
     *  xxx:{
     *      target:xxx
     *      type:QLineEdit
     *  }
     * }
    */
    void config(const QString &key, QObject *object);
    void config(const QString &key, const QString &objName, const QString &clsName);
    void set(QWidget *widget, QVariantMap data);
    QVariantMap get(QWidget *widget);

private:
    QWidget* findObjectDirectly(QWidget *widget, const QStringList &objNames);
    void findObjectAndSet(QWidget *widget, const QString &objName, const QString &clsName, const QVariant &data);
    bool findObjectAndGet(QWidget *widget, const QString &objName, const QString &clsName, QVariant &data);

private:
    QMap<QString,QPair<QString,QString>> _keyInfo;
};

#endif
